﻿using System;
using System.Collections;
using System.IO;
using System.Net;
using System.Text;
using UnityEngine;
using ZerAx.Net;

namespace BlockOS.Client
{
    public class RemoteWorld : BaseWorld
    {
        private TcpConnection local;
        private IPEndPoint remoteEP;
        
        public RemoteWorld(IPEndPoint ep)
        {
            local = new TcpConnection();
            remoteEP = ep;

            entityStorage = new EntityDataStorage(100);
        }

        public override IConnection GetConnection()
        {
            return local;
        }

        public override IEnumerator Init(Action<string> logger)
        {
            logger("Connecting...");

            local.Connect(remoteEP);
            while (!local.IsConnecting) yield return null;

            yield return base.Init(logger);
        }
    }
}
